package com.tg.data.http.entity;

import android.os.Parcel;
import android.os.Parcelable;

import io.objectbox.annotation.Entity;
import io.objectbox.annotation.Id;
import io.objectbox.annotation.Transient;

@Entity
public class OsdItem implements Parcelable {
    public static final short OSDF_ABS_POSITION = 0x0001;
    public static final short OSDF_DISABLED = 0x0002;
    public static final short OSDF_DELETE = 0x0004;
    public static final short OSD_MIN_ID = 0;
    public static final int OSD_TYPE_TEXT = 1;
    public static final short OSD_STATE_NORMAL = 0;
    public static final int OSDP_RIGHTBOTTOM  = 8;

    @Id
    public   long id;//设备ID

    public String getUuid() {
        return uuid;
    }

    public void setUuid(String uuid) {
        this.uuid = uuid;
    }

    public  String uuid;//设备UUID
    public short itemId = 0;
    public short flags;
    public int type;

    public int pos;
    public short x, y;
    public byte alignment;
    @Transient
    public byte[] reserved = new byte[3];
    public int len;
    @Transient
    public byte[] data = new byte[1];
    public String text;

    public OsdItem(){
        flags = OSD_STATE_NORMAL;
        type = OSD_TYPE_TEXT;
        pos = OSDP_RIGHTBOTTOM;
    }

    protected OsdItem(Parcel in) {
        id = in.readLong();
        uuid = in.readString();
        itemId = (short) in.readInt();
        flags = (short) in.readInt();
        type = in.readInt();
        pos = in.readInt();
        x = (short) in.readInt();
        y = (short) in.readInt();
        alignment = in.readByte();
        reserved = in.createByteArray();
        len = in.readInt();
        data = in.createByteArray();
        text = in.readString();
    }

    @Override
    public void writeToParcel(Parcel dest, int flags) {
        dest.writeLong(id);
        dest.writeString(uuid);
        dest.writeInt((int) itemId);
        dest.writeInt((int) flags);
        dest.writeInt(type);
        dest.writeInt(pos);
        dest.writeInt((int) x);
        dest.writeInt((int) y);
        dest.writeByte(alignment);
        dest.writeByteArray(reserved);
        dest.writeInt(len);
        dest.writeByteArray(data);
        dest.writeString(text);
    }

    @Override
    public int describeContents() {
        return 0;
    }

    public static final Creator<OsdItem> CREATOR = new Creator<OsdItem>() {
        @Override
        public OsdItem createFromParcel(Parcel in) {
            return new OsdItem(in);
        }

        @Override
        public OsdItem[] newArray(int size) {
            return new OsdItem[size];
        }
    };
}
